/*
    PhotoFlip, a free 3d photo managment suite.
    Copyright (C) 2007  Elisée MAURER, Gaétan WALTER
    
    This file is part of PhotoFlip.
    Contact: http://www.photoflip.org/

    PhotoFlip is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    PhotoFlip is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with PhotoFlip.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DOCK_HPP_INCLUDED
#define DOCK_HPP_INCLUDED

#include <vector>
#include <cmath>

#include <cairomm/surface.h>
#include <cairomm/context.h>

#include <GL/gl.h>

#include "library.hpp"

struct dockIcon {
	dockIcon();
	dockIcon(std::string action, GLuint texture, bool visible = true);
	
	std::string action;
	GLuint texIcon;
	bool visible;
};

//! The %dock, providing cool UI
/*!
  It's a smooth, shiny and colorful way for the user to interact with PhotoFlip.
*/
class dock {
	private:
		library *m_lib;
		// dock height
		int m_height;
		// dock state
		bool m_risen;
		float m_raiseValue;
		// dock wigets
		std::vector<dockIcon> m_icons;
		std::vector<std::string> m_location;
		
		// surfaces / texture
		Cairo::RefPtr<Cairo::ImageSurface> m_cairoSurface;
		Cairo::RefPtr<Cairo::Context> m_cairoContext;
		GLuint m_texDock;
	public:
		dock(library *lib);
		~dock();
		
		void initTexture();
		int computeLocationBarWidth();
		int computeBasketWidth();
		int computeWidth();
		
		void clearIcons();
		void packIcon(std::string action, GLuint texIcon, bool visible = true);
		dockIcon *getIcon(std::string action);
		
		void pushLocation(std::string location);
		void popLocation();
		void clearLocation();
				
		void setSize(int width, int height);
		void raise(bool state = true);
		void raise(int x, int y);
		
		std::string getAction(int x);
		int getBasketPhoto(int x);
		
		bool update();
		void render();
};

#endif // DOCK_HPP_INCLUDED
